
<title>部门管理</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>平台管理</cite></a>
        <a><cite>部门管理</cite></a>
    </div>
</div>


<div id="dept-app" class="layui-fluid" v-cloak>

    <div class="layui-inline">
        <div class="layui-btn-group">
            <button :class="{'layui-btn layui-btn-sm layui-btn-disabled':Disabled(),'layui-btn layui-btn-sm':!Disabled()}" v-bind:disabled="Disabled()" v-on:click="Edit"><i class="fa fa-pencil-square-o"></i>  修改</button>
            <button :class="{'layui-btn layui-btn-sm layui-btn-disabled':Disabled(),'layui-btn layui-btn-sm':!Disabled()}" v-bind:disabled="Disabled()" v-on:click="Delete"><i class="fa fa-trash-o"></i>  删除</button>
            <button class="layui-btn layui-btn-sm" v-on:click="Add"><i class="fa fa-plus"></i>  添加</button>
        </div>

        <input id="txt_keyword" type="text" class="layui-input layui-input-inline" placeholder="名称" style="width:200px;height:32px;" v-model="SearchModel.keyword">
        <button id="btn_search" type="button" class="layui-btn layui-btn-sm" v-on:click="Search"><i class="fa fa-search"></i></button>
    </div>


    <table class="table table-hover layui-table">
        <thead>
            <tr>
                <th style="width:20px;"></th>
                <th>名称</th>
                <th>编号</th>
                <th>负责人</th>
                <th>手机</th>
                <th>创建时间</th>
                <th>备注</th>

            </tr>
        </thead>
        <tbody>
            <tr v-for="(item,index) in Models" :class="{'selected':SelectedModel == item}" v-on:click="SelectRow(item)">
                <td>{{ GetOrdinal(index) }}</td>
                <td>{{ item.Name }}</td>
                <td>{{ item.EnCode }}</td>
                <td>{{ item.Manager }}</td>
                <td>{{ item.MobilePhone }}</td>
                <td>{{ item.CreationTime|yyyy_mm_dd_hh_mm_ss }}</td>
                <td>{{ item.Description }}</td>
            </tr>
        </tbody>
        <tfoot is="ling-footer" v-bind:options="PageOptions" v-on:change="ToPage"> </tfoot>
    </table>
    <form id="dept-dailog" v-show="IsShow" class="layui-form" style="padding:10px;">

        <!--<form id="form1" class="layui-form">-->
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">

                <input id="Name" name="Name" type="text" lay-verify="verifyName" class="layui-input" placeholder="请输入名称" v-model="Model.Name" />
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">编号</label>
            <div class="layui-input-block">
                <input id="EnCode" name="EnCode" type="text" lay-verify="required|number" class="layui-input" placeholder="请输入编号" v-model="Model.EnCode" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <input id="Manager" name="Manager" type="text" class="layui-input" v-model="Model.Manager" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">

                <input id="MobilePhone" name="MobilePhone" type="text" maxlength="11" class="layui-input" v-model="Model.MobilePhone" />
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea id="Description" name="Description" class="layui-input" style="height: 60px;" v-model="Model.Description"></textarea>
            </div>
        </div>
        <!--<div class="layui-form-item">
            <label class="layui-form-label">启用</label>
            <div class="layui-input-block">
                <input type="checkbox" name="open" lay-skin="switch" lay-text="ON|OFF">
            </div>
        </div>-->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="save">保存</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重填</button>-->
            </div>
        </div>
    </form>
</div>



<script>

    layui.use(['admin', 'laypage', 'table', 'form', 'ling'], function () {
        var $ = layui.$;
        var table = layui.table;
        var laypage = layui.laypage;
        var form = layui.form;
        var dialogIndex;
        var ling = layui.ling;

        var app = $('#dept-app').Grid({
            SearchUrl: "/SystemManage/Department/GetModels"
            , DeleteUrl: "/SystemManage/Department/Delete"
            , EditUrl: "/SystemManage/Department/Update"
            , AddUrl: "/SystemManage/Department/Add"
            , DialogConfig: function () {
                return {
                    title: app.Title,
                    area: ['620px'], //宽高
                    content: $("#dept-dailog"),//root.find("#frmEdit"),
                    opened: function (index) {
                        dialogIndex = index;
                        form.render();
                    }
                };
            }
        });


        //自定义验证规则
        form.verify({
            verifyName: function (value) {
                if (value.length < 2) {
                    return '至少得2个字符啊';
                }
            }
        });
        ////监听提交
        form.on('submit(save)', function (data) {
            var code = app.Save();
            if (code == 0 && dialogIndex)
                layer.close(dialogIndex);
            return false;
        });
    });
</script>
